package com.imot.service.impl;

import com.imot.pojo.vo.FailureRateWaveformVo;
import com.imot.pojo.vo.FaultCategoryStatsVo;
import com.imot.pojo.vo.HealthyStatusVo;
import com.imot.pojo.vo.HistAlertStatsVo;
import com.imot.response.Result;
import com.imot.service.HealthyStatusService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * ClassName: getHealthyStatusImpl
 * Description:
 * date: 2023/11/13 18:48
 *
 * @author imot-jiah.wang
 */
@Service
public class HealthyStatusImpl implements HealthyStatusService {
    @Override
    public Result getHealthyStatus() {
        HealthyStatusVo healthyStatusVo = new HealthyStatusVo();
        healthyStatusVo.setStatus("正常");
        healthyStatusVo.setActivationCount("195次");
        healthyStatusVo.setActivationCountChange("1％");
        healthyStatusVo.setWeeklyAlertCount("3次");
        healthyStatusVo.setWeeklyAlertCountChange("33％");
        healthyStatusVo.setWeeklyOnTime("32小时40分钟");
        healthyStatusVo.setWeeklyOnTimeChange("12％");
        healthyStatusVo.setEffectiveAlertPercentage("98%");
        healthyStatusVo.setEffectiveAlertPercentageChange("1％");
        healthyStatusVo.setWeeklyRunTime("30小时40分钟");
        healthyStatusVo.setWeeklyRunTimeChange("12％");
        return Result.success(healthyStatusVo);
    }

    @Override
    public Result getHistAlertStats() {
        HistAlertStatsVo histAlertStatsVo = new HistAlertStatsVo();

        histAlertStatsVo.setFaultAlertsList(null);
        histAlertStatsVo.setFaultConfirmationsList(null);
        return Result.success(histAlertStatsVo);
    }

    @Override
    public Result getFaultCategoryStats() {
        FaultCategoryStatsVo faultCategoryStatsVo = new FaultCategoryStatsVo();
        faultCategoryStatsVo.setMechanicalFault(5.0F);
        faultCategoryStatsVo.setElectricalComponentFault(3.0F);
        faultCategoryStatsVo.setOtherFault(2.0F);
        faultCategoryStatsVo.setCumulativeFault(10.0F);
        return Result.success(faultCategoryStatsVo);
    }

    @Override
    public Result getFailureRateWaveform() {
        FailureRateWaveformVo failureRateWaveformVo = new FailureRateWaveformVo();

// 创建警戒值列表
        List<HashMap<Object, Object>> thresholdValueList = new ArrayList<>();
        HashMap<Object, Object> thresholdMap1 = new HashMap<>();
        thresholdMap1.put("time", "2023-11-01");
        thresholdMap1.put("value", 100);
        HashMap<Object, Object> thresholdMap2 = new HashMap<>();
        thresholdMap2.put("time", "2023-11-02");
        thresholdMap2.put("value", 120);

        // 添加到列表
        thresholdValueList.add(thresholdMap1);
        thresholdValueList.add(thresholdMap2);

// 创建标准值列表
        List<HashMap<Object, Object>> standardValueList = new ArrayList<>();
        HashMap<Object, Object> standardMap1 = new HashMap<>();
        standardMap1.put("time", "2023-11-01");
        standardMap1.put("value", 80);
        HashMap<Object, Object> standardMap2 = new HashMap<>();
        standardMap2.put("time", "2023-11-02");
        standardMap2.put("value", 90);

        // 添加到列表
        standardValueList.add(standardMap1);
        standardValueList.add(standardMap2);
        // 设置到 failureRateWaveformVo 对象
        failureRateWaveformVo.setThresholdValueList(thresholdValueList);
        failureRateWaveformVo.setStandardValueList(standardValueList);

        return Result.success(failureRateWaveformVo);
    }
}

